(All L1/L2 Products) Improved Geolocation for Browse PNGs and KMLs#161
Open
nemo794 wants to merge 25 commits intoisce-framework:mainfrom
Open
(All L1/L2 Products) Improved Geolocation for Browse PNGs and KMLs#161nemo794 wants to merge 25 commits intoisce-framework:mainfrom
nemo794 wants to merge 25 commits intoisce-framework:mainfrom
Conversation
added 25 commits
March 24, 2026 15:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR closes #61 .
WIP -- PR is ready for RSLC, GSLC, GCOV, RIFG, RUNW, and GUNW. Unfortunately, testing on edge cases for ROFF and GOFF shows that the quiver arrows are not "behaving" nicely in the polar regions; ROFF/GOFF needs more testing work to go. However, the major design pattern changes for this PR are implemented; review on that code can begin while ROFF/GOFF finishes being debugged.
Improve Browse Image Geolocation Accuracy and Add EPSG 4326 Support
Summary
This PR resolved two critical geolocation issues with NISAR QA browse images and adds optional EPSG 4326 (lat/lon) browse generation for all 8 product types (RSLC, GSLC, GCOV, RIFG, RUNW, GUNW, ROFF, GOFF).
Problems Solved
Issue 1: Incorrect Coordinate Grid for Browse Images
Problem: Browse PNG images retained their source coordinate grid (range-doppler for L1, UTM/polar stereo for L2),
making the image's pixels not correctly geolocated in standard GIS tools expecting lat/lon coordinates.
Solution: Added optional generation of "EPSG 4326 (lat/lon) Browse" images alongside the original "Primary Browse", enabled via
output_browse_4326: truein runconfig.Issue 2: Inaccurate KML Corner Coordinates
Problem: KML corner coordinates were computed from the full-resolution source raster but browse images are
multilooked/decimated to smaller sizes. This caused browse images to not align correctly when overlaid in Google Earth.
Solution: Now compute KML corners from the actual decimated/multilooked coordinate grids, ensuring pixel-perfect
alignment.
Impact
User Benefits
nisarqanisarqato generate browse, reports, etc. (when file verification `.. is set to false.)PR Review Strategy
This is a large PR but it's structured logically:
I recommend reviewing in 3 passes:
Pass 1: High-Level Understanding
Pass 2: Core Infrastructure
Pass 3: Product-Specific Changes
See "Review Plan" section below for more detailed guidance.
Changes Overview
New Features
Core Infrastructure Added
BrowseOutputPathsclass for centralized management of browse file pathsBrowse4326ParamGroupparameter classes (L1Radar/L2Geo variants) for centralized management of new runconfig parameters for generating the 4326 Browse.grid.downsample()method with configurable downsampling modesgrid.save_kml()method for consistent KML generation from actual coordinate gridsgeocode_radar_raster()- Geocodes range-Doppler grid rasters (float) to geocoded rasters; accommodates any EPSG.reproject_geo_raster()- GDAL Warps geocoded rasters to a new EPSG_get_multilooked_center_coordinates()utility for sub-pixel accuracy; handles odd/even nlooks correctly when multilookingWorkflows Updated (All 8)
Level-1 (Radar) - using ISCE3 geocoding:
Level-2 (Geocoded) - using GDAL reprojection:
File Naming Convention
BROWSE.png,BROWSE.kmlBROWSE_4326.png,BROWSE_4326.kmlOutput Files Generated:
With output_browse_4326: false (default):
With output_browse_4326: true:
Backward Compatibility for Mission Operations
false)output_browse_4326: false. (Same output files generated)Technical Approach
KML
latlonquadCorner Accuracy Fix (Issue #2)Primary Browse + (optional) EPSG 4326 Generation pseudocode (Issue #1)
For Level-1 (Radar) products:
For Level-2 (Geo) products:
Technical Diagram: Processing Flow
flowchart TD; A[Input NISAR Product] --> B[Load Source Raster<br/>Full Resolution]; B --> C[Downsample<br/>to Primary Browse Size<br/>Track ky, kx]; C --> D[Apply Image Correction<br/>gamma, clipping, etc.]; D --> E[Create Downsampled Grid<br/>for Primary Browse]; E --> F[Save Primary Browse.png<br/>Save Primary BROWSE.kml<br/>with Accurate Corners<br/> **Fix for Issue #2**]; F --> G{optional:<br/>output_browse_4326 ?}; G -->|yes| H[Geocode/Reproject to EPSG 4326<br/>- L1: ISCE3 geocoding<br/>- L2: GDAL reprojection<br/> **Fix for Issue #1** ]; H --> I[Save BROWSE_4326.png<br/>Save BROWSE_4326.kml];Testing Performed
Functional Testing
✅ All 8 product types tested with real NISAR data
✅ Both frequencies (A and B) verified
✅ Multiple polarizations tested (SHNA, DHDH, QPDH, NASV)
Visual Validation
✅ KML overlays verified in Google Earth for accuracy
✅ Antimeridian crossing cases tested and working
✅ Polar regions with polar stereo projections validated
✅ Before/after comparison confirms corner accuracy improvements
Edge Cases
✅ Different EPSG codes (UTM zones, polar stereo)
✅ Antimeridian crossing
✅ Level 1 Browse Products with/without DEM files
Suggested Sample Outputs & Screenshots
Screenshots/Figures
TODO
F. Example Runconfig Snippets
F1: Minimal config (default behavior)
F2: Enable EPSG 4326 for L1 Radar (RSLC/RIFG/RUNW/ROFF)
F3: Enable EPSG 4326 for L2 Geo (GSLC/GCOV/GUNW/GOFF)
Review Strategy for Teammates
(copy-paste from above)
This PR is large but logically structured. I recommend reviewing in 3 passes:
Pass 1: High-Level Understanding
Pass 2: Core Infrastructure
Pass 3: Product-Specific Changes
Pass 1: High-Level Understanding
Goal: Understand what problems are being solved and verify the approach
Files to review:
Questions to answer:
Pass 2: Core Infrastructure
Goal: Review the foundational utilities that all products depend on
Files:
Comments on design changes for: src/nisarqa/grids.py
Coordinate Grid, GeoGrid, and RadarGrid dataclasses:
- These were moved from src/nisarqa/raster_classes.py to a new file, src/nisarqa/grids.py.
- Previously, these were inherited by GeoRaster and RadarRaster dataclasses. With this new PR, that inheritance design pattern becomes too cumbersome to maintain. The code has been updated to use a composition design pattern, where each Raster "has a" CoordinateGrid attribute.
- These dataclasses were enhanced with several new methods, including downsample() and save_kml() methods.
Pass 3: Product-Specific Changes
Goal: Verify infrastructure is applied correctly and consistently
Review products in groups (they follow similar patterns):
Section 3A: Backscatter Products
Products: RSLC, GSLC, GCOV
Files:
Section 3B: Interferogram Products
Products: RIFG, RUNW, GUNW
Files:
Section 3C: Offset Products
Products: ROFF, GOFF
Files: